<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!doctype html PUBLIC "-//W3c//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>已播列表</title>
    <jsp:include page="/commons/common-js.jsp"></jsp:include>
    
    <!-- 电话插件 -->
    <!-- C9E29294-7FB3-4221-BB36-B91462C32746 -->
    <!-- <object classid="clsid:C4751F74-C039-4272-8532-11F7ACBAD184" id="JDComPort1"
          name="JDComPort1"  
          Width="0"   
          height="0">
	</object> -->
</head>
<body>
<div style="margin:0 auto; width:97%; float:none; display:block;margin-top: 10px;">
	            <strong>业务员:</strong>&nbsp;&nbsp;&nbsp;<input class="easyui-textbox" type="text" id="jobName2" name="jobName2" style="width: 200px;"></input>&nbsp;&nbsp;
	          <strong>电话号码:</strong>&nbsp;&nbsp;&nbsp;<input class="easyui-textbox" type="text" id="phone2" name="phone2" style="width: 200px;"></input>&nbsp;&nbsp;
	         <strong>日期:</strong>&nbsp;&nbsp;&nbsp;<input id="startTime" class="easyui-datebox"></input>&nbsp;&nbsp;&nbsp;
	         <strong>-</strong>&nbsp;&nbsp;&nbsp;<input id="endTime" class="easyui-datebox" validType="md['#startTime']"></input>
	         <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="submitParamsForm()">查找</a>&nbsp;&nbsp;
	         <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearParam()">重置</a>&nbsp;&nbsp;
</div>
<div style="width: 100%;overflow:auto;margin-top: 10px;" id="tablediv">
    <div style="margin:0 auto; width:97%; float:none; display:block;">
        <table id="recordList" class="easyui-datagrid" title=" " height="auto" style="width:100%;overflow:hidden;">
            <thead>
            <tr>
            	<!-- <th data-options="field:'ck',checkbox:true"></th> -->
                <th data-options="field:'devid',align:'center',width:'5%',formatter:formatFontsize">设备号</th>
                <th data-options="field:'jobNum',align:'center',width:'10%',formatter:formatFontsize">工号</th>
                <th data-options="field:'name',align:'center',width:'10%',formatter:formatFontsize">姓名</th>
                <th data-options="field:'phone',align:'center',width:'10%',formatter:formatFontsize">电话</th>
                <th data-options="field:'remark',align:'center',hidden:true">备注</th> 
                <th data-options="field:'recordStartTime',align:'center',width:'15%',formatter:TAOTAO.formatDateTime">拨打时间</th>
                <th data-options="field:'recordFile',align:'center',width:'30%',formatter:formatFontsize">录音</th> 
                <th data-options="field:'id',width:'20%',align:'center',formatter:formatOper">操作</th>
            </tr>
            </thead>
        </table>
    </div>
 </div>
<script type="text/javascript">
/* 时间校验 */
var varify;//用于查询验证,验证开始时间是否小于结束时间 
var startTime;
var endTime;
$.fn.datebox.defaults.formatter = function(date){//对于时间格式的转换 
	startTime = $('#startTime').datebox('getValue');
	endTime = $('#endTime').datebox('getValue');
	var y = date.getFullYear(); 
	var m = fullnum(date.getMonth()+1); 
	var d = fullnum(date.getDate()); 
	return y+'-'+m+'-'+d; 
	}; 
	function fullnum(obj){//对于月小于10格式的转换,因为Timestamp转换必须是2013-01-04这种格式 
	if(Number(obj) < 10){ 
	return '0' + obj; 
	}else{ 
	return obj; 
	} } 

	$.extend($.fn.validatebox.defaults.rules, {//验证开始时间小于结束时间 
	md: { 
	validator: function(value, param){ 
	startTime2 = $(param[0]).datetimebox('getValue'); 
	var d1 = $.fn.datebox.defaults.parser(startTime2); 
	var d2 = $.fn.datebox.defaults.parser(value);
	varify=d2>=d1; 
	return varify; 

	}, 
	message: '结束时间要大于或等于开始时间！' 
	} 
	})
	
	
function onSelect(date){
	alert(date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate());
}
	        
$(function(){
	submitParamsForm();
})


function formatOper(val,row,index){
	
		return '<a href="javascript:void(0)" style="font-size:15px"'+
		'onclick="remark('+val+')">备注</a>&nbsp;&nbsp;&nbsp;&nbsp;' +
		'<a href="'+row.recordFile+'" style="font-size:15px">下载录音</a>&nbsp;&nbsp;&nbsp;&nbsp;';
		
}
function formatFontsize(value,row,index){
	if(value != null){
		return '<span style="font-size:15px">'+value+'</span>';
	}
    
}

//自定义判空封装方法
function checkNull(id){
	var val = trim($("#"+id).val());
	$("#"+id).val(val);
	if(val == null || val.length == 0){
		return false;
	}else{
		return true;
	}
}
function trim(str){       
		return str.replace(/^(\s|\u00A0)+/,'').replace(/(\s|\u00A0)+$/,'');       
}
/* 提交 */
function submitParamsForm(){
	//校验
	var jobName = trim($("#jobName2").val());
	//$("#jobName").val(jobName)
	var phone = trim($("#phone2").val());
	if(varify || (startTime === undefined && endTime === undefined)){
		if(startTime != undefined && endTime != undefined){
		startTime = $('#startTime').datebox('getValue');
		endTime = $('#endTime').datebox('getValue');
		alert("time:"+startTime+":"+endTime); 
			}
	$('#recordList').datagrid({
        title: " ",
        url: "${pageContext.request.contextPath}/phone/record_list?jobName="+jobName+"&phone="+phone+
        "&startTime="+startTime+"&endTime="+endTime, 
        loadMsg: '正在加载信息...',
        iconCls: "icon-grid",
        singleSelect: true,
        striped: true,
        fitColumns: true,
        singleSelect: true,
        pagination: true,
        rownumbers: false,
        pageSize: 20,
        pageList: [15, 20, 30, 40, 50],
        onLoadError: function () {
            $.messager.alert('查询出错', '加载数据出错');
        },
        onLoadSuccess: function (data) {
            if (data.rows.length == 0) {
                var body = $(this).data().datagrid.dc.body2;
                body.find('table tbody').append('<tr><td width="' + body.width() + '" style="height: 25px; text-align: center; color:Red;">没有数据</td></tr>');
            }

        }
    });
	}else{
	$.messager.alert('警告','结束时间要大于或等于开始时间','warning'); 
	} 
	//不校验时间
	/* $('#recordList').datagrid({
        title: " ",
        url: "${pageContext.request.contextPath}/phone/record_list?jobName="+jobName+"&phone="+phone, 
        loadMsg: '正在加载信息...',
        iconCls: "icon-grid",
        singleSelect: true,
        striped: true,
        fitColumns: true,
        singleSelect: true,
        pagination: true,
        rownumbers: false,
        pageSize: 20,
        pageList: [15, 20, 30, 40, 50],
        onLoadError: function () {
            $.messager.alert('查询出错', '加载数据出错');
        },
        onLoadSuccess: function (data) {
            if (data.rows.length == 0) {
                var body = $(this).data().datagrid.dc.body2;
                body.find('table tbody').append('<tr><td width="' + body.width() + '" style="height: 25px; text-align: center; color:Red;">没有数据</td></tr>');
            }

        }
    }); */
}

/* 重置 */
function clearParam(){
	
	$('#startTime').combo('setText','');
	$('#endTime').combo('setText',''); 
	$('#jobName2').combo('setText',''); 
	$('#phone2').combo('setText',''); 
	$("#jobName2").val("");
	$("#phone2").val("");
	startTime = undefined; 
	endTime = undefined; 
}

</script>
<!-- <script src="http://mediaplayer.yahoo.com/latest"></script> -->

</body>


</html>